#include <REGX52.H>

int dat=0;
void UART_Init()
{

	SCON=0x50; 
	PCON = 0x00;
	TMOD = 0x20;		//设置定时器模式
	TL1 = 0xFD;		//设定定时初值
	TH1 = 0xFD;		//设定定时器重装值
	TR1 = 1;		//启动定时器1
	EA=1;
	ES=1;
}

void UART_SendByte(unsigned char Byte)
{
	SBUF=Byte;
	while(TI==0);
	TI=0;
}

	
void main()
{
	UART_Init();
	while(1)
	{
	P1_1=dat;
	}
}
void UART_Routine() interrupt 4
{
	if(RI==1)					//如果接收标志位为1，接收到了数据
	{
		dat=1;
		RI=0;					//接收标志位清0
	}
}
